This replication file includes all the analysis used in the article "Believing What Politicians Communicate: Ideological Presentation of Self and Voters' Perceptions of Politician Ideology" forthcoming at BJPS. For questions about anything in here feel free to email Kevin Reuning (kevin.reuning@gmail.com)

It does not include the initial data used to create some of the ideological measures (voter perception and messaging ideology). The voter perception data is based on the (C)CES data which has its own dataverse. The messaging ideology data is created from Twitter and Facebook content which is not shareable. For additional information about these measures please contact Kevin Reuning (voter perception) or Michael Heseltine (messaging ideology). 

All analysis here used R 4.5.0, to install all relevant packages run:

```
install.packages("pak")
pak::pak(c("cowplot", "estimatr", "GGally", "ggpubr", "gt", "gtExtras", "gtsummary", "marginaleffects", "mgcv", "modelr", "modelsummary", "randomForest", "tidyverse"))
```

## Script

The Analysis.R script contains everything (I apologize). I've tried to provide clear labels of what section does what. Everything outputs to an `Out` directory.

## Data

There are two main datasets: `candidate_data.csv` and `incumbent_data.csv` they contain the data for the candidate or incumbent analysis. The variables are mostly the same so we describe them below. The only difference is that the legislative ideology and facebook ideology variables are not present for the candidates. 

They are described in column order (for the incumbent data): 

- Twitter_Ideo: The estimated ideology of individual's twitter account. 
- nokken_poole_dim1: The Nokken-Poole legislative ideology measure as taken from the VoteView Nominate data. 
- party: Party code (100 == Democrat; 200==Republican; other == other)
- year: The year
- Candidate: Candidate name (should be standardized)
- seat: The seat they were running for OR an incumbent of. 
- ico.status: Whether they were an incumbent or not (1=incumbent). 
- mean: The mean voter perception ideology estimate
- Democrat: Whether they are a Democrat or not (based on caucusing) Yes or No
- tweets: The number of tweets used in the twitter estimate. 
- state: The state they are from. 
- PVI: The partisan lean of a district/state (taken from various sources and in some cases calculated by the authors).
- web_ideology: The ideology based on their websites (complete estimates are/will be available at https://github.com/crcase/WEB-Scores )
- fb_ideo_avg: The messaging ideology based on facebook content. 
- ggum_ideo: The GGUM measure of legislative ideology.
- Posts: The number of facebook posts used to create the facebook ideology score. 
- tweets_wout_classifier: The number of tweets used for the twitter ideology score estimated without classifying political/non-political tweets (this was a robustness measure).
- ideo_wout_classifier: The twitter ideology estimated without the classifier (robustness measure)
- Macroeconomics to Immigration: The proportion of tweets in each category. 


In addition to the two other datasets the plot_data.csv is used to create Figures 1 and 2. These are slightly different as they include all incumbents (not just those running for re-election). 